<template>
	<view style="padding-bottom: 70rpx; box-sizing: border-box;">
		<view class="title">{{name}}</view>
		<view class="main">
			<view class="main-item" v-for="(item,index) in list" :key="index">
				<view class="item-title">{{index+1}}.{{item.name}}</view>
				<view v-if="item.pid==1">
					<view class="item-content flex" v-for="el in item.di" :key="index">
						<span class="dan"></span>
						<text>{{el.name}}</text>
					</view>
				</view>
				<view v-if="item.pid==2">
					<view class="item-content flex" v-for="el in item.di" :key="index">
						<span class="duo"></span>
						<text>{{el.name}}</text>
					</view>
				</view>
				<view v-if="item.pid==3">
					<view class="item-contents">
						<input />
					</view>
				</view>
			</view>
		</view>
		<view class="bts" @tap='asqCopy'>现在编辑</view>
	</view>
</template>

<script>
	import api from "@/common/api.js";
	import {
		baseURL
	} from "@/common/http.js";
	export default {
		data() {
			return {
				id: '',
				name: '',
				list: [],
				moid: '',
				wenid: ''
			};
		},
		methods: {
			asqCopy() {
				api.look({
					moid: this.moid,
					nameid: uni.getStorageSync('message')[0].id,
					api: 'modao'
				}).then(res => {
					if(res && res.code == 200) {
						this.wenid = res.date.wenid
						uni.showToast({
							title: '复制成功',
							icon: 'success',
							duration: 1500,
							success: () => {
								setTimeout(() => {
									uni.navigateTo({
										url: '../editDiaocha/editDiaocha?wenid=' + this.wenid
									})
								}, 1500)
							}
						})
					}
				}).catch(err => {
					console.log(err)
				})
			}
		},
		onShareAppMessage(options) {
			let shareObj = {
				success: (res) => {
					if (res.errMsg == 'shareAppMessage:ok') {
						uni.showToast({
							title: '分享成功',
							icon: 'success',
							duration: 1500
						})
					}
				},
				fail: () => {
					if (res.errMsg == 'shareAppMessage:fail cancel') {
						uni.showToast({
							title: '取消分享',
							icon: 'none',
							duration: 2000
						})
					} else if (res.errMsg == 'shareAppMessage:fail') {
						// 转发失败，其中 detail message 为详细失败信息
					}
				},
				complete: () => {
					// 转发结束之后的回调（转发成不成功都会执行）
				}
			}
		},
		onLoad(options) {
			this.id = options.id
			let data = {
				api: 'wenmocha',
				id: options.id
			}
			api.look(data).then(res => {
				if (res.code == 200) {
					this.name = res.date[0].name
					this.list = res.date[0].text
					this.moid = res.date[0].id
				}
			}).catch(err => {
				console.log(err)
			})
		}
	}
</script>

<style lang="scss">
	.title {
		width: 100%;
		height: 100rpx;
		line-height: 100rpx;
		text-align: center;
		font-size: 36rpx;
		color: #007AFF;
		font-weight: 500;
	}

	.main {
		width: 690rpx;
		margin: 0 auto;

		.main-item {
			margin: 15rpx 0;

			.item-title {
				color: #333;
				font-size: 30rpx;
			}
		}
	}

	.item-content {
		height: 60rpx;
		line-height: 60rpx;

		.dan {
			width: 25rpx;
			height: 25rpx;
			margin: 0 10rpx;
			border-radius: 50%;
			border: 1rpx solid #DFDFDF;
		}

		.duo {
			width: 30rpx;
			height: 30rpx;
			margin: 0 10rpx;
			border-radius: 5%;
			border: 1rpx solid #DFDFDF;
		}
	}

	.item-contents {
		input {
			width: 90%;
			height: 60rpx;
			line-height: 60rpx;
			border: 1rpx solid #DFDFDF;
			border-radius: 10rpx;
			margin: 10rpx 0;
		}
	}

	.bts {
		width: 690rpx;
		height: 90rpx;
		line-height: 90rpx;
		text-align: center;
		border-radius: 45rpx;
		background: #007AFF;
		color: #fff;
		font-size: 36rpx;
		font-weight: 500;
		margin: 100rpx auto 0;
	}
</style>
